package com.qfedu.myproject.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;



import com.qfedu.myproject.service.UserService;
import com.qfedu.myproject.vo.DataGridResult;
import com.qfedu.myproject.vo.Message;
import com.qfedu.myproject.vo.Query;
import com.qfedu.myproject.vo.R;

@Controller
@RequestMapping("/sys/user")
public class SysUserController {
	
	@Autowired
	private UserService user ;
	@RequestMapping("/{page}")
	public String index(@PathVariable String page) {
		System.out.println("hello");
		return "sys/user/" + page;
	}
	
	@ResponseBody
	@RequestMapping("/message")
	public R getMessage(){
		System.out.println("message");
		return user.getMessage();
	}
	
	@RequestMapping("/delete")
	@ResponseBody
	public R delete(@RequestBody Long[] ids) {
		return user.deleteByIdList(ids);
	}
	
	@RequestMapping("/edit")
	@ResponseBody
	public R edit(@RequestBody Long[] ids) {
		return user.editByIdList(ids);
	}
	
	@RequestMapping("/list")
	@ResponseBody
	public DataGridResult getPage(@RequestParam Map<String, Object> params) {
		System.out.println(params+"hhhh");
		Query query = new Query(params);
		return user.getPageList(query);
	}
	
	
	@RequestMapping("/output")
	public String getOutput() {
		return "sys/user/out";
	}
	
	

}
